<?php
if(isset($message) == TRUE) :
?>
<div class="notification <?php echo $message['type'] ?> png_bg">
    <a class="close" href="#"><img alt="close" title="Đóng" src="<?php echo Url::site('assets/admin/images/icons/cross_grey_small.png') ?>"></a>
    <div><?php echo $message['content'] ?></div>
</div>
<?php
endif;
?>

<div class="clear"></div>
<div class="content-box"><!-- Start Content Box -->
    <div class="content-box-header">
        <h3>Sửa thông tin bài viết</h3>
        <div class="clear"></div>
    </div> <!-- End .content-box-header -->
    <div class="content-box-content">
        <form method="post" action="<?php echo Url::site('admin/article/edit/' . $article->id) ?>">
            <fieldset>
                <p>
                    <label>Tiêu đề</label>
                    <input type="text" name="title" class="text-input medium-input" value="<?php echo $article->title ?>" />
                </p>
                <p>
                    <label>Tóm tắt</label>
                    <textarea rows="15" cols="49" name="summary" class="text-input textarea"><?php echo $article->summary ?></textarea>
                </p>
                <p>
                    <label>Nội dung</label>
                    <textarea rows="15" cols="79" name="content" class="text-input textarea tinymce"><?php echo $article->content ?></textarea>
                </p>
                <p>
                    <label>Thư mục đăng tin</label>
                    <?php echo $category->render() ?>
                    <select class="small-input" name="dropdown">
                    </select>
                </p>
                
                <p>
                    <label>Trạng thái</label>
                    <select name="status">
                        <?php foreach(Article::getStatusAsArray() as $key => $value): ?>
                        <option <?php if($article->status == $key){ echo 'selected'; } ?> value="<?php echo $key; ?>"><?php echo $value; ?></option>
                        <?php endforeach; ?>
                    </select>
                </p>
                
                <p>
                    <input type="submit" name="submit" value="Đăng tin" class="button">
                </p>
            </fieldset>
            <div class="clear"></div><!-- End .clear -->
        </form>
    </div> <!-- End .content-box-content -->
</div>
<script type="text/javascript">
$(function(){
    Sidebar.setActive(Sidebar.menu.article, 0);

        $('select[name="category_id"] option').each(function(index, elem) {
            if(elem.value == <?php echo $article->category_id ?>) {
                elem.selected = true;
                return;
            }
        });
});
</script>